import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:todo_app/components/Overlay/OverlayConfirm.dart';
import 'package:todo_app/components/Overlay/OverlayToast.dart';
import 'package:todo_app/components/TextExt.dart';
import 'package:todo_app/layout/CustomCard.dart';
import 'package:todo_app/layout/Gaps.dart';
import 'package:todo_app/layout/Header.dart';
import 'package:todo_app/layout/ListItem.dart';
import 'package:todo_app/utils/AppNavigator.dart';

class MeSettingsPage extends HookWidget {
  const MeSettingsPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const Header(title: "设置"),
      body: Column(
        children: [
          CustomCard(
            margin: EdgeInsets.only(top: 15.dp),
            child: Column(
              children: [
                ListItem(
                  height: 44.dp, 
                  title: TextExt.title("关于我们", lineHeight: 1),
                  onTap: () { AppNavigator.pushNamed("aboutUs"); }, 
                  border: true,
                  nextIcon: true,
                ),
                ListItem(
                  height: 44.dp, 
                  title: TextExt.title("清除缓存", lineHeight: 1), 
                  onTap: () {
                    showOverlayToast("清除成功");
                  },
                  nextIcon: true,
                ),
              ],
            )
          ),
          CustomCard(
            margin: EdgeInsets.only(top: 15.dp),
            child: Column(
              children: [
                ListItem(
                  height: 44.dp, 
                  title: TextExt.title("退出应用", lineHeight: 1), 
                  onTap: () async { 
                    var index = await showOverlayConfirm(
                      title: "提示",
                      content: "确定要退出应用吗?",
                      actions: [
                        OverlayConfirmAction.cancle(),
                        OverlayConfirmAction.ok()
                      ]
                    );
                    if(index == 1) {
                      AppNavigator.pushNamed("login");
                    }
                  }, 
                  border: true,
                  nextIcon: true,
                ),
              ],
            )
          )
        ],
      ),
    );
  }
}